﻿<UserControl x:Class="VSMAggregator.Views.GreenView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:View="clr-namespace:Jounce.Framework.View;assembly=Jounce" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    
    <Grid x:Name="LayoutRoot" Background="Green" Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
        <Grid.RenderTransform>
            <TranslateTransform/>
        </Grid.RenderTransform>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="NavigationStates">
                <VisualStateGroup.States>
                    <VisualState x:Name="Default"/>
                    <VisualState x:Name="ShowState">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="HideState">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup.States>
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1" To="ShowState">                          
                        <Storyboard Duration="0:0:1">
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)"
                                             From="0" To="1"/>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                                             From="205" To="0"/>
                        </Storyboard>
                    </VisualTransition>
                    <VisualTransition GeneratedDuration="0:0:1" From="ShowState" To="HideState">
                        <Storyboard Duration="0:0:1">
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)"
                                             From="1" To="0"/>
                            <DoubleAnimation Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                                             From="0" To="205"/>
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Interactivity:Interaction.Behaviors>
            <View:VisualStateSubscriptionBehavior EventName="NavigateGreen" StateName="ShowState" UseTransitions="True"/>
            <View:VisualStateSubscriptionBehavior EventName="NavigateRed" StateName="HideState" UseTransitions="True"/>
        </Interactivity:Interaction.Behaviors>
        <TextBlock 
            FontSize="16"
            Margin="10"
            TextWrapping="Wrap" Text="This is the green view. There is no view model, it is just static text in a view-only scenario."/>
        <Button Margin="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Content=" BACK ">
            <Interactivity:Interaction.Triggers>
                <Interactivity:EventTrigger EventName="Click">
                    <View:VisualStateAggregatorTrigger EventName="NavigateRed"/>
                </Interactivity:EventTrigger>
            </Interactivity:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>
